package com.lanou.dao.impl;

import com.lanou.bean.Shop;
import com.lanou.dao.ShopDao;
import com.lanou.utils.JDBCUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class ShopDaoImpl implements ShopDao {
    private Connection connection;
    private PreparedStatement pstm;
    private ResultSet rs;
    @Override
    public void insert(Shop shop) throws Exception {
        String sql = "INSERT into shop_list (id, title, des,furniture,detail) VALUES (?,?,?,?,?)";

        connection = JDBCUtils.getConnection();
        pstm = connection.prepareStatement(sql);

        pstm.setInt(1,shop.getId());
        pstm.setString(2,shop.getTitle());
        pstm.setString(3,shop.getDes());
        pstm.setInt(4,shop.getFurniture());
        pstm.setInt(5,shop.getDetail());

        pstm.executeUpdate();
        JDBCUtils.close(pstm, connection);
    }
}
